import { IPSAppDEUILogicNode } from '../../app/dataentity/ipsapp-deuilogic-node';
import { IPSDEUILogicLink } from './ipsdeuilogic-link';
import { IPSDEUILogicNode } from './ipsdeuilogic-node';
import { IPSDEUILogicNodeParam } from './ipsdeuilogic-node-param';
import { IPSDEUILogicParam } from './ipsdeuilogic-param';
import { IPSSysPFPlugin } from '../../res/ipssys-pfplugin';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDEUILogicNodeImpl extends PSModelObjectImpl implements IPSDEUILogicNode, IPSAppDEUILogicNode {
  get codeName(): string {
    return this.M.codeName;
  }

  protected dstpsdeuilogicparam: IPSDEUILogicParam | null = null;

  getDstPSDEUILogicParam(): IPSDEUILogicParam | null {
    if (this.dstpsdeuilogicparam != null) return this.dstpsdeuilogicparam;
    const value = this.M.getDstPSDEUILogicParam;
    if (value == null) {
      return null;
    }
    this.dstpsdeuilogicparam = this.getPSModel4('dataentity.logic.IPSDEUILogicParam', value, 'getDstPSDEUILogicParam') as IPSDEUILogicParam;
    return this.dstpsdeuilogicparam;
  }

  get dstPSDEUILogicParam(): IPSDEUILogicParam | null {
    return this.getDstPSDEUILogicParam();
  }

  getDstPSDEUILogicParamMust(): IPSDEUILogicParam {
    const value = this.getDstPSDEUILogicParam();
    if (value == null) {
      throw new Error('未指定目标逻辑参数对象');
    }
    return value;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get height(): number {
    return this.M.height != null ? this.M.height : 0;
  }

  get leftPos(): number {
    return this.M.leftPos != null ? this.M.leftPos : 0;
  }

  get logicNodeType():
    | 'BEGIN'
    | 'PREPAREJSPARAM'
    | 'RESETPARAM'
    | 'COPYPARAM'
    | 'BINDPARAM'
    | 'APPENDPARAM'
    | 'SORTPARAM'
    | 'RENEWPARAM'
    | 'VIEWCTRLINVOKE'
    | 'VIEWCTRLFIREEVENT'
    | 'PFPLUGIN'
    | 'MSGBOX'
    | 'DEACTION'
    | 'DEDATASET'
    | 'DELOGIC'
    | 'DEUIACTION'
    | 'THROWEXCEPTION'
    | 'DEBUGPARAM'
    | 'END' {
    return this.M.logicNodeType;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psdeuilogiclinks: IPSDEUILogicLink[] | null = null;

  getPSDEUILogicLinks(): IPSDEUILogicLink[] | null {
    if (this.psdeuilogiclinks == null) {
      this.psdeuilogiclinks = this.fillChildListModel(this.M.getPSDEUILogicLinks, 'dataentity.logic.IPSDEUILogicLink') as IPSDEUILogicLink[];
    }
    return this.psdeuilogiclinks;
  }

  get psDEUILogicLinks(): IPSDEUILogicLink[] | null {
    return this.getPSDEUILogicLinks();
  }

  findPSDEUILogicLink(objKey: any): IPSDEUILogicLink | null {
    return this.getPSModel5('dataentity.logic.IPSDEUILogicLink', this.getPSDEUILogicLinks(), objKey) as IPSDEUILogicLink;
  }

  protected psdeuilogicnodeparams: IPSDEUILogicNodeParam[] | null = null;

  getPSDEUILogicNodeParams(): IPSDEUILogicNodeParam[] | null {
    if (this.psdeuilogicnodeparams == null) {
      this.psdeuilogicnodeparams = this.fillChildListModel(this.M.getPSDEUILogicNodeParams, 'dataentity.logic.IPSDEUILogicNodeParam') as IPSDEUILogicNodeParam[];
    }
    return this.psdeuilogicnodeparams;
  }

  get psDEUILogicNodeParams(): IPSDEUILogicNodeParam[] | null {
    return this.getPSDEUILogicNodeParams();
  }

  findPSDEUILogicNodeParam(objKey: any): IPSDEUILogicNodeParam | null {
    return this.getPSModel5('dataentity.logic.IPSDEUILogicNodeParam', this.getPSDEUILogicNodeParams(), objKey) as IPSDEUILogicNodeParam;
  }

  protected pssyspfplugin: IPSSysPFPlugin | null = null;

  getPSSysPFPlugin(): IPSSysPFPlugin | null {
    if (this.pssyspfplugin != null) return this.pssyspfplugin;
    const value = this.M.getPSSysPFPlugin;
    if (value == null) {
      return null;
    }
    this.pssyspfplugin = this.getPSModel4('res.IPSSysPFPlugin', value, 'getPSSysPFPlugin') as IPSSysPFPlugin;
    return this.pssyspfplugin;
  }

  get psSysPFPlugin(): IPSSysPFPlugin | null {
    return this.getPSSysPFPlugin();
  }

  getPSSysPFPluginMust(): IPSSysPFPlugin {
    const value = this.getPSSysPFPlugin();
    if (value == null) {
      throw new Error('未指定前端模板插件对象');
    }
    return value;
  }

  protected srcpsdeuilogicparam: IPSDEUILogicParam | null = null;

  getSrcPSDEUILogicParam(): IPSDEUILogicParam | null {
    if (this.srcpsdeuilogicparam != null) return this.srcpsdeuilogicparam;
    const value = this.M.getSrcPSDEUILogicParam;
    if (value == null) {
      return null;
    }
    this.srcpsdeuilogicparam = this.getPSModel4('dataentity.logic.IPSDEUILogicParam', value, 'getSrcPSDEUILogicParam') as IPSDEUILogicParam;
    return this.srcpsdeuilogicparam;
  }

  get srcPSDEUILogicParam(): IPSDEUILogicParam | null {
    return this.getSrcPSDEUILogicParam();
  }

  getSrcPSDEUILogicParamMust(): IPSDEUILogicParam {
    const value = this.getSrcPSDEUILogicParam();
    if (value == null) {
      throw new Error('未指定源逻辑参数对象');
    }
    return value;
  }

  get topPos(): number {
    return this.M.topPos != null ? this.M.topPos : 0;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get width(): number {
    return this.M.width != null ? this.M.width : 0;
  }

  get parallelOutput(): boolean {
    return this.M.parallelOutput != null ? this.M.parallelOutput : false;
  }

  get cls(): string {
    return 'PSDEUILogicNodeImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'app.dataentity.IPSAppDEUILogicNode' || cls == 'dataentity.logic.IPSDEUILogicNode') return true;
    return super.instanceof(cls);
  }
}
